﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UIT.Controls.Containers;
using System.Windows.Markup;

namespace UIT.Animations
{
    [ContentProperty("Animations")]
    public class StoryBoard : IContainer<StoryBoard, IAnimation>, IDisposable
    {
        public StoryBoard()
        {
            Animations = new DisposableObservableCollection<StoryBoard, IAnimation>(this);
        }

        public void Start()
        {
            UIT.Context.Current.Storyboard.Start(this);
        }

        public void Pause()
        {
            UIT.Context.Current.Storyboard.Pause(this);
        }

        public void Resume()
        {
            UIT.Context.Current.Storyboard.Resume(this);
        }

        public void Stop(bool goToEnd)
        {
            UIT.Context.Current.Storyboard.Stop(this, goToEnd);
        }

        public DisposableObservableCollection<StoryBoard, IAnimation> Animations { get; set; }

        IDisposableObservableCollection<StoryBoard, IAnimation> IContainer<StoryBoard, IAnimation>.Children
        {
            get { return Animations; }
        }

        public void Dispose()
        {
            if (Animations != null)
                Animations.Dispose();
            Animations = null;
        }

        public Controls.IControl Target { get; set; }

        public string TargetStyleProperty { get; set; }
    }
}
